//
//  HomeViewController.m
//  GiftNotes
//
//  Created by wsh on 15/8/11.
//  Copyright (c) 2015年 wsh. All rights reserved.
//

#import "HomeViewController.h"
#import "HomeMenueView.h"
#import "MainBaseViewController.h"
#import "HomeCommonData.h"

@interface HomeViewController ()<HomeMenuDelegate>

@property (nonatomic, strong)UIBarButtonItem *leftBarButtonItem;
@property (nonatomic, strong)HomeMenueView *menu;


@end

@implementation HomeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self creatMenue];
    
    self.navigationController.navigationBar.tintColor = [UIColor colorWithRed:1.0 green:0.585 blue:0.865 alpha:1.0];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


#pragma mark - 创建下拉菜单

- (void)creatMenue
{
    _leftBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"精选" style:UIBarButtonItemStylePlain target:self action:@selector(doTapLeftBarButton:)];
    _leftBarButtonItem.tintColor = [UIColor redColor];
    
    self.navigationItem.leftBarButtonItem = _leftBarButtonItem;
    
    NSArray *array = @[@"精选", @"礼物", @"美食", @"数码", @"运动", @"娱乐"];
    _menu = [[HomeMenueView alloc]initWithFrame:CGRectMake(10, 70, 70, 300) array:array];
    _menu.delegate = self;
    
}

- (void)doTapLeftBarButton:(UIBarButtonItem *)sender
{
    if (_menu.isShow) {
        [self.menu menuDismiss];
    } else {
        [self.menu menuShow:self.navigationController];
    }
}

- (void)transportMenuName:(NSString *)name index:(NSInteger)index
{
    self.navigationItem.leftBarButtonItem.title = name;
    
    HomeCommonData *data = [HomeCommonData defaultData];
    NSString *classStr = data.classArray[index];
    NSLog(@"%@",classStr);
    
}


/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
